import java.util.Scanner;
public class runnian
{
	public static void main(String args[])
	{
		Scanner run = new Scanner(System.in);
		int year = run.nextInt();
		boolean temp = false;
		int n = 0;
		if (year>2000&&year<=2100)
		{
			temp=true;
			n=year;
		}
		else
		{
			temp=false;
		}
		if(temp)
		{
			for(int i=2004; i<=n;i++)
			{
				if((i%4==0&&i%100!=0)||i%400==0)
				{
					System.out.println(i);
				}
			}
		}
		else
		{
			System.out.println("Invalid year!");
		}
	}
}
